<?php
	require_once 'commentModel.php';
	function getTopPlaceModel()
	{
		$topIdList = getTopPlaceFromComment();
		if($topIdList){
			$topPlace = array();
			foreach($topIdList as $topIdKey => $topIdValue){
					$stInfoPlace = file_get_contents("http://localhost/zingmesdk/model/webservice/get_place_from_id.php?id=".$topIdValue->place_id);
					$json = json_decode($stInfoPlace);
					foreach($json as $key => $value) {
						if(strcmp($key,'success')==0){
							if($value==1){
								foreach($json as $key => $value){
									if (is_array($value)) {
										$value['total_comment'] = $topIdValue->total_comment;
										$topPlace[] = $value;
									}
								}
							}
						}
					}

			}
			return $topPlace;
		}
		else{
			return false;
		}
	}
	
	function getNewsetPlaceModel(){
		$string = file_get_contents("http://localhost/zingmesdk/model/webservice/get_newest_place.php");
		$json = json_decode($string);
		foreach($json as $key => $value) {
			if(strcmp($key,'success')==0){
                if($value==1){
					foreach($json as $key => $value)
						if (is_array($value)) {
							return $value;
						}
				}
				else{
					return false;
				}
			}
		}
	}
?>